#!/usr/bin/perl -w

use SOAP::Lite;

$soap_response = SOAP::Lite
   -> uri('urn:Flight')
   #-> proxy('http://localhost:8181/cgi-bin/my-flights.cgi')
   -> proxy('http://homepages.feis.herts.ac.uk/~ts3br/cgi-bin/my-flights.cgi')
   -> on_fault(  sub {
                         my($soap, $res) = @_;
                         warn "SOAP Error (): " ,
                              ref $res
                                ? "fs: ".$res->faultstring . ', fc: '.$res->faultcode . ', fd: '. $res->faultdetail
                                : "tr: ".$soap->transport->status;
			exit;
                         return 0;
                 })
   ->checkSeatAvailability('EJ286', '03/10/2008');
  $origin = $soap_response->result;
  if($origin eq NULL){
  	$message = "No data return";
  }else{
	  @res = $soap_response->paramsout;
	  $res[2] =~ s/ / at /;
	  $res[3] =~ s/ / at /;

	  $message = "Flight from $origin to $res[0] \n";
	  $message .= "Flight code EJ286 \n";
	  $message .= "Using $res[1] \n";
	  $message .= "Departure date on $res[2] \n";
	  $message .= "Arriving date on $res[3] \n";
	  $message .= "duartion of journey $res[4] \n";
	  $message .= "With seat availability $res[5] in first, $res[6] in business, $res[7] in economy \n";
  }
  print $message;
